//
//  BSHeaderView.m
//  BS
//
//  Created by lanou on 15/8/14.
//  Copyright (c) 2015年 lanou. All rights reserved.
//

#import "BSHeaderView.h"

#import "UIImageView+WebCache.h"

#import "BSUserViewController.h"
@implementation BSHeaderView


//自定义头试图
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    if (self)
    {
        NSArray* objects = [[NSBundle mainBundle] loadNibNamed:@"BSHeaderView"owner:self options:nil];
        UIView *nibView = [objects firstObject];
        UIView *contentView = self.contentView;
        CGSize contentViewSize = contentView.frame.size;
        nibView.frame = CGRectMake(0, 0, contentViewSize.width, contentViewSize.height);
        self.profileImageView = (UIImageView *)[nibView viewWithTag:10];
        //头像变圆
        self.profileImageView.layer.cornerRadius = 15;
        self.profileImageView.layer.masksToBounds = YES;
        UITapGestureRecognizer *gest = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(toUser)];
        [self addGestureRecognizer:gest];
        self.nameLabel = (UILabel *)[nibView viewWithTag:11];
        self.passtimeLabel = (UILabel *)[nibView viewWithTag:12];
        [contentView addSubview:nibView];
    }
    return self;
}

- (void)toUser{

    NSLog(@"用户");
    BSUserViewController *userVC = [[BSUserViewController alloc] init];
    [self.nav pushViewController:userVC animated:YES];
}


- (void)setModel:(BSListModel *)model{
    
    _model = model;
    _nameLabel.text = model.name;
    _passtimeLabel.text = model.passtime;
    [_profileImageView sd_setImageWithURL:[NSURL URLWithString:model.profile_image]];
}
@end
